<template>

  <div class="zy-content">
    <back-level></back-level>
    <!--    <Modal :mask-closable="false"-->
    <!--            v-model="sendInfoVisible"-->
    <!--            :title="`${$t('preliminary.FinalAcceptanceFATContent')}`"-->
    <!--            :fullscreen="true"-->
    <!--            :footer-hide="true"-->
    <!--            @on-visible-change="handleVisibleChange"-->
    <!--    >-->
    <Form ref="acceptanceAddForm" :model="formItem" :label-width="200">

    <Card :title="$t('preliminary.BasicInformation')" class="detail-content-layout">
      <div class="basic-info">
<!--        <div class="basic-info-title">-->
<!--          <h2>{{$t('preliminary.BasicInformation')}}</h2>-->
<!--        </div>-->
        <div class="">
          <Row style="border-top: 1px solid #eee;border-bottom: 1px solid #eee">
            <Col span="8">
              <FormItem :label="`${$t('preliminary.ContractNumber')}:`">
                <div class="basic-info-body-item">{{ formItem.contractNo }}</div>
              </FormItem>
            </Col>
            <Col span="8">
              <FormItem :label="`${$t('equipmentscrapped.AssetNo')}:`">
                <div class="basic-info-body-item">{{ formItem.assetsNo }}</div>
              </FormItem>
            </Col>
            <Col span="8">
              <FormItem :label="`${$t('equipmentscrapped.Name')}:`">
                <div class="basic-info-body-item">
                  <Tooltip max-width="500" v-if="formItem.deviceName">
                    <div class="over-wrapper">{{ formItem.deviceName }}</div>
                    <div slot="content">
                      <p>{{ formItem.deviceName }}</p>
                    </div>
                  </Tooltip>
                  <!--                                    {{ formItem.deviceName }}-->
                </div>
              </FormItem>
            </Col>
          </Row>
          <Row style="border-bottom: 1px solid #eee">
            <Col span="8">
              <FormItem :label="`${$t('equipCheck.Model')}:`">
                <div class="basic-info-body-item">
                  <Tooltip max-width="500" v-if="formItem.specification">
                    <div class="over-wrapper">{{ formItem.specification }}</div>
                    <div slot="content">
                      <p>{{ formItem.specification }}</p>
                    </div>
                  </Tooltip>
                  <!--                                    {{ formItem.specification }}-->
                </div>
              </FormItem>
            </Col>
            <Col span="8">
              <FormItem :label="`${$t('preliminary.ManufacturingNumber')}:`">
                <div class="basic-info-body-item">{{ formItem.factoryNo }}</div>
              </FormItem>
            </Col>
            <Col span="8">
              <FormItem :label="`${$t('preliminary.Manufacturer')}:`">
                <div class="basic-info-body-item">
                  <Tooltip max-width="500" v-if="formItem.manufacturer">
                    <div class="over-wrapper">{{ formItem.manufacturer }}</div>
                    <div slot="content">
                      <p>{{ formItem.manufacturer }}</p>
                    </div>
                  </Tooltip>
                  <!--                                    {{ formItem.manufacturer }}-->
                </div>
              </FormItem>
            </Col>
          </Row>
          <Row style="border-bottom: 1px solid #eee">
            <Col span="8">
              <FormItem :label="`${$t('preliminary.ManufacturingDate')}:`">
                <div class="basic-info-body-item">{{ formItem.produceDate }}</div>
              </FormItem>
            </Col>
            <Col span="8">
              <FormItem :label="`${$t('preliminary.Vendor')}:`">
                <div class="basic-info-body-item">{{ formItem.supplier }}</div>
              </FormItem>
            </Col>
            <Col span="8">
              <FormItem :label="`${$t('preliminary.Entity')}:`">
                <div class="basic-info-body-item">{{ formItem.belongCompanyName }}</div>
              </FormItem>
            </Col>
          </Row>
          <Row style="border-bottom: 1px solid #eee">
            <!--                        <Col span="8">-->
            <!--                            <FormItem label="使用公司">-->
            <!--                                <div class="basic-info-body-item">{{ formItem.useCompanyName }}</div>-->
            <!--                            </FormItem>-->
            <!--                        </Col>-->
            <Col span="8">
              <FormItem :label="`${$t('preliminary.Department')}:`">
                <div class="basic-info-body-item">{{ formItem.useDept }}</div>
              </FormItem>
            </Col>
            <Col span="8">
              <FormItem :label="`${$t('preliminary.Location')}:`">
                <div class="basic-info-body-item">{{ formItem.position4 }}</div>
              </FormItem>
            </Col>
          </Row>
        </div>
      </div>
    </Card>
      <Card :title="$t('preliminary.FATInformation')" class="detail-content-layout mt16">
        <div class="basic-info">
          <div class="basic-info-title mb16">
<!--            <h2>{{$t('preliminary.FATInformation')}}</h2>-->
            <Button type="primary" ghost shape="circle" icon="md-add" @click="handleAddCheck">{{$t('acceptanceCheck.AddAcceptanceCriteria')}}</Button>
          </div>
          <div class="mb16">
            <Row style="border-top: 1px solid #eee;border-bottom: 1px solid #eee">
              <Col span="8">
                <FormItem :label="`${$t('preliminary.PlannedAcceptanceTestDate')}:`">
                  <div class="basic-info-body-item">
                    <!--                                  {{ formItem.yjyst }}-->
                    <DatePicker
                        @on-change="handleChangeDate"
                        class="date"
                        type="date"
                        format="yyyy-MM-dd"
                        :placeholder="`${$t('common.selectInfo')}`"
                        v-model="formItem.yjyst"
                    ></DatePicker>
                  </div>
                </FormItem>
              </Col>
              <Col span="8">
                <FormItem :label="`${$t('preliminary.ActualAcceptanceTestDate')}:`">
                  <div class="basic-info-body-item">{{ formItem.finalAcceptDate }}</div>
                </FormItem>
              </Col>
              <Col span="8">
                <FormItem :label="`${$t('preliminary.Technicalappendix')}:`">
                  <div class="basic-info-body-item">
                    <!--                                  <Upload-->
                    <!--                                      ref="fileUpload"-->
                    <!--                                      :show-upload-list="false"-->
                    <!--                                      :before-upload="handleJSBeforeUpload"-->
                    <!--                                      type="drag"-->
                    <!--                                      action=""-->
                    <!--                                  >-->
                    <!--                                    <Button type="primary">{{$t('preliminary.Upload')}}</Button>-->
                    <!--                                  </Upload>-->
                    <div class="file-list" v-for="(item, index) in jsFiles" :key="index" >
                      <div class="item-src">{{ item.fileName }}</div>
                      <Icon class="item-icon"
                            type="ios-close" size="20" style="float:right;"
                            @click="delJSFileList(index)" v-if="item"></Icon>
                    </div>
                  </div>
                </FormItem>
              </Col>
            </Row>
            <Row>
              <!--                        <Col span="4" offset="4">-->
              <!--                            <div class="file-list" v-for="(item, index) in pList" :key="index" >-->
              <!--                                <div class="item-src" @click="handlePreview(item)">{{ item.fileName }}</div>-->
              <!--                            </div>-->
              <!--                        </Col>-->
              <!--                        <Col span="4" offset="4">-->
              <!--                            <div class="file-list" v-for="(item, index) in aList" :key="index" >-->
              <!--                                <div class="item-src" @click="handlePreview(item)">{{ item.fileName }}</div>-->
              <!--                            </div>-->
              <!--                        </Col>-->

              <!--                        <Col span="4" offset="20">-->
              <!--                            <div class="file-list" v-for="(item, index) in formItem.jszlFile" :key="index" >-->
              <!--                                <div class="item-src" @click="handlePreview(item)">{{ item.fileName }}</div>-->
              <!--                            </div>-->
              <!--                        </Col>-->
            </Row>
          </div>
          <div class="tableContent">
            <Table
                :columns="columns"
                :data="formItem.checkList"
            >
              <template slot-scope="{ row, index }" slot="checkTarget">
                <template v-if="row.showStatus" >{{row.checkTarget}}</template>
                <Input v-else :value="row.checkTarget" @on-change="handleTarget($event, index)"/>
              </template>
              <template slot-scope="{ row, index }" slot="checkContent">
                <template v-if="row.showStatus" >{{row.checkContent}}</template>
                <Input  v-else :value="row.checkContent" @on-change="handleContent($event, index)"/>
              </template>
              <template slot-scope="{ row, index }" slot="checkResult">
                <RadioGroup v-model="row.checkResult" @on-change="handleResult($event, index)">
                  <Radio v-for="item in types" :key="item.id" :label="item.id">{{ item.value }}</Radio>
                </RadioGroup>
              </template>
              <template slot-scope="{ row, index }" slot="checkDesc">
                <template v-if="row.showStatus" >{{row.checkDesc}}</template>
                <Input v-else :value="row.checkDesc" @on-change="handleDesc($event, index)"/>
              </template>
              <template slot-scope="{ row }" slot="version">
                <template>{{row.version}}</template>
                <!--                        <template v-if="row.showStatus" >{{row.version}}</template>-->
                <!--                        <Input  v-else :value="row.version" @on-change="handleVersion($event, index)"/>-->
              </template>
              <!--                        <template slot-scope="{ row, index }" slot="action">-->
              <!--                            <span class="operationBtn" @click="handleDelete(index)">{{$t('common.Delete')}}</span>-->
              <!--                        </template>-->
            </Table>
          </div>
        </div>
      </Card>

      <!--            <div class="basic-info" v-show="isShow">-->
      <!--                <div class="basic-info-title">-->
      <!--                    <h2>验收结果</h2>-->
      <!--                </div>-->
      <!--                <div class="basic-info-body">-->
      <!--                    <Row style="border-top: 1px solid #eee;border-bottom: 1px solid #eee">-->
      <!--                        <Col span="8">-->
      <!--                            <FormItem label="随机工具/备件">-->
      <!--                                <div class="basic-info-body-item">-->
      <!--                                    <RadioGroup v-model="sjFlag">-->
      <!--                                        <Radio v-for="equ in packages" :key="equ.id" :label="equ.id">{{ equ.value }}</Radio>-->
      <!--                                    </RadioGroup>-->
      <!--                                </div>-->
      <!--                            </FormItem>-->
      <!--                        </Col>-->
      <!--                        <Col span="8">-->
      <!--                            <FormItem label="技术资料">-->
      <!--                                <div class="basic-info-body-item">-->
      <!--                                    <RadioGroup v-model="finallyFlag">-->
      <!--                                        <Radio v-for="equ in packages" :key="equ.id" :label="equ.id">{{ equ.value }}</Radio>-->
      <!--                                    </RadioGroup>-->
      <!--                                </div>-->
      <!--                            </FormItem>-->
      <!--                        </Col>-->
      <!--                        <Col span="8">-->
      <!--                            <FormItem label="厂家培训">-->
      <!--                                <div class="basic-info-body-item">-->
      <!--                                    <RadioGroup v-model="cjFlag">-->
      <!--                                        <Radio v-for="equ in tranings" :key="equ.id" :label="equ.id">{{ equ.value }}</Radio>-->
      <!--                                    </RadioGroup>-->
      <!--                                </div>-->
      <!--                            </FormItem>-->
      <!--                        </Col>-->
      <!--                    </Row>-->
      <!--                </div>-->
      <!--                <Row>-->
      <!--                    <Col span="4" offset="4">-->
      <!--                        <div class="file-list" v-for="(item, index) in formItem.sjfjFile" :key="index" >-->
      <!--                            <div class="item-src" @click="handlePreview(item)">{{ item.fileName }}</div>-->
      <!--                        </div>-->
      <!--                    </Col>-->
      <!--                    <Col span="4" offset="4">-->
      <!--                        <div class="file-list" v-for="(item, index) in formItem.zxjszlFile" :key="index" >-->
      <!--                            <div class="item-src" @click="handlePreview(item)">{{ item.fileName }}</div>-->
      <!--                        </div>-->
      <!--                    </Col>-->
      <!--                    <Col span="4" offset="4">-->
      <!--                        <div class="file-list" v-for="(item, index) in formItem.cjpxFile" :key="index" >-->
      <!--                            <div class="item-src" @click="handlePreview(item)">{{ item.fileName }}</div>-->
      <!--                        </div>-->
      <!--                    </Col>-->
      <!--                </Row>-->
      <!--            </div>-->
      <!--            <div class="basic-info" v-show="!gFlag && isShow">-->
      <!--                <div class="basic-info-title">-->
      <!--                    <h2>A系列精度检测结果</h2>-->
      <!--                </div>-->
      <!--                <div class="basic-info-body">-->
      <!--                    <Row style="border-top: 1px solid #eee;border-bottom: 1px solid #eee">-->
      <!--                        <Col span="8">-->
      <!--                            <FormItem label="检测精度">-->
      <!--                                <div class="basic-info-body-item">-->
      <!--                                    <RadioGroup v-model="aFlag">-->
      <!--                                        <Radio v-for="equ in checks" :key="equ.id" :label="equ.id">{{ equ.value }}</Radio>-->
      <!--                                    </RadioGroup>-->
      <!--                                </div>-->
      <!--                            </FormItem>-->
      <!--                        </Col>-->
      <!--                        <Col span="8">-->
      <!--                            <FormItem label="检测时间">-->
      <!--                                <div class="basic-info-body-item">-->
      <!--                                    {{ formItem.ajd_create_time }}-->
      <!--                                </div>-->
      <!--                            </FormItem>-->
      <!--                        </Col>-->
      <!--                        <Col span="8">-->
      <!--                            <FormItem label="检测人">-->
      <!--                                <div class="basic-info-body-item">-->
      <!--                                    {{ formItem.accuracy_user_name }}-->
      <!--                                </div>-->
      <!--                            </FormItem>-->
      <!--                        </Col>-->
      <!--                    </Row>-->
      <!--                </div>-->
      <!--                <Row>-->
      <!--                    <Col span="4" offset="4">-->
      <!--                        <div class="file-list" v-for="(item, index) in formItem.ajdFile" :key="index" >-->
      <!--                            <div class="item-src" @click="handlePreview(item)">{{ item.fileName }}</div>-->
      <!--                        </div>-->
      <!--                    </Col>-->
      <!--                </Row>-->
      <!--            </div>-->
      <!--            <div class="basic-info" v-show="!aFlag && isShow">-->
      <!--                <div class="basic-info-title">-->
      <!--                    <h2>G系列精度检测结果</h2>-->
      <!--                </div>-->
      <!--                <div class="basic-info-body">-->
      <!--                    <Row style="border-top: 1px solid #eee;border-bottom: 1px solid #eee">-->
      <!--                        <Col span="8">-->
      <!--                            <FormItem label="检测精度">-->
      <!--                                <div class="basic-info-body-item">-->
      <!--                                    <RadioGroup v-model="gFlag">-->
      <!--                                        <Radio v-for="equ in checks" :key="equ.id" :label="equ.id">{{ equ.value }}</Radio>-->
      <!--                                    </RadioGroup>-->
      <!--                                </div>-->
      <!--                            </FormItem>-->
      <!--                        </Col>-->
      <!--                        <Col span="8">-->
      <!--                            <FormItem label="检测时间">-->
      <!--                                <div class="basic-info-body-item">-->
      <!--                                    {{ formItem.gjd_create_time }}-->
      <!--                                </div>-->
      <!--                            </FormItem>-->
      <!--                        </Col>-->
      <!--                        <Col span="8">-->
      <!--                            <FormItem label="检测人">-->
      <!--                                <div class="basic-info-body-item">-->
      <!--                                    {{ formItem.accuracy_user_name }}-->
      <!--                                </div>-->
      <!--                            </FormItem>-->
      <!--                        </Col>-->
      <!--                    </Row>-->
      <!--                </div>-->
      <!--                <Row>-->
      <!--                    <Col span="4" offset="4">-->
      <!--                        <div class="file-list" v-for="(item, index) in formItem.gjdFile" :key="index" >-->
      <!--                            <div class="item-src" @click="handlePreview(item)">{{ item.fileName }}</div>-->
      <!--                        </div>-->
      <!--                    </Col>-->
      <!--                </Row>-->
      <!--            </div>-->
      <!--            <div class="basic-info" v-show="isShow">-->
      <!--                <div class="basic-info-title">-->
      <!--                    <h2>验收人员</h2>-->
      <!--                </div>-->
      <!--                <div class="basic-info-body">-->
      <!--                    <Row style="border-top: 1px solid #eee;border-bottom: 1px solid #eee">-->
      <!--                        <Col span="8">-->
      <!--                            <FormItem label="设备管理员">-->
      <!--                                <div class="basic-info-body-item">{{ formItem.belongCompanyAdminName }}</div>-->
      <!--                            </FormItem>-->
      <!--                        </Col>-->
      <!--                        <Col span="8">-->
      <!--                            <FormItem label="所属公司验收人员">-->
      <!--                                <div class="basic-info-body-item">{{ formItem.belongCompanyAcceptorName }}</div>-->
      <!--                            </FormItem>-->
      <!--                        </Col>-->
      <!--                        <Col span="8">-->
      <!--                            <FormItem label="厂务中心验收人员">-->
      <!--                                <div class="basic-info-body-item">{{ formItem.factoryAdminName }}</div>-->
      <!--                            </FormItem>-->
      <!--                        </Col>-->
      <!--                    </Row>-->
      <!--                    <Row>-->
      <!--                        <Col span="8" style="border-bottom: 1px solid #eee">-->
      <!--                            <FormItem label="采购员">-->
      <!--                                <div class="basic-info-body-item">{{ formItem.buyer }}</div>-->
      <!--                            </FormItem>-->
      <!--                        </Col>-->
      <!--                        <Col span="8" style="border-bottom: 1px solid #eee">-->
      <!--                            <FormItem label="使用公司验收人">-->
      <!--                                <div class="basic-info-body-item">{{ formItem.useCompanyAcceptorName }}</div>-->
      <!--                            </FormItem>-->
      <!--                        </Col>-->
      <!--                    </Row>-->
      <!--                </div>-->
      <!--            </div>-->
    </Form>
    <!--        <div class="btn-wrapper">-->
    <!--            <Row :gutter="16" class="btn-action">-->
    <!--                <Col span="12" offset="12">-->
    <!--                    <Button style="margin-right: 10px;" type="primary" :loading="loadingVisible" @click="handleSave">{{$t('common.Save')}}</Button>-->
    <!--&lt;!&ndash;                    <Button style="margin-right: 10px;" type="primary" ghost @click="exportCheck">下载验收文件</Button>&ndash;&gt;-->
    <!--&lt;!&ndash;                    <Button style="margin-right: 10px;" type="primary" ghost @click="exportAorG('A')">下载A系列精度检测文件</Button>&ndash;&gt;-->
    <!--&lt;!&ndash;                    <Button style="margin-right: 10px;" type="primary" ghost @click="exportAorG('G')">下载G系列精度检测文件</Button>&ndash;&gt;-->
    <!--                </Col>-->
    <!--            </Row>-->
    <!--        </div>-->
    <!--    </Modal>-->
    <bottom-handle-wrap>
      <Button style="margin-right: 10px;" type="primary" :loading="loadingVisible" @click="handleSave">{{$t('common.Save')}}</Button>
    </bottom-handle-wrap>
  </div>

</template>

<script>
    import fileDownload from 'js-file-download'
    export default {
        name: "addCheckModal",
        data() {
            return {
                sjFlag: '',
                finallyFlag: '',
                cjFlag: '',
                aFlag: '',
                gFlag: '',
                result: '',
                isShow: false,
                sendInfoVisible: false,
                loadingVisible: false,
                formItem: {},
                jsFiles:[],
                packages: [{id: 1, value:this.$t('acceptanceCheck.alreadyArrived')},{id: 0, value: this.$t('acceptanceCheck.NotYetArrived')}],
                tranings: [{id: 1, value: this.$t('acceptanceCheck.trained')},{id: 0, value: this.$t('acceptanceCheck.untrained')}],
                checks: [{id: 1, value:this.$t('acceptanceCheck.checked')},{id: 0, value: this.$t('acceptanceCheck.unchecked')}],
                types: [{id: 1, value: this.$t('acceptanceCheck.Qualified')},{id: 2, value: this.$t('acceptanceCheck.Unqualified')}],
              columns: [
                {
                  title: `${ this.$t('preliminary.AcceptanceTestIndex') }`,
                  key: 'checkTarget',
                  align: 'center',
                  slot: 'checkTarget',
                  // minWidth: 120
                  renderHeader: (h) => {
                    return h('div',[
                      h('span',{
                        style: {
                          color: '#ff0000',
                        },
                        domProps: {
                          innerHTML: '*'
                        }
                      }),
                      h('span',{
                        domProps: {
                          innerHTML: this.$t('preliminary.AcceptanceTestIndex')
                        }
                      })
                    ])
                  }
                },
                {
                  title: `${ this.$t('preliminary.AcceptanceTestContent') }`,
                  key: 'checkContent',
                  align: 'center',
                  slot: 'checkContent',
                  // minWidth: 120,
                  renderHeader: (h) => {
                    return h('div',[
                      h('span',{
                        style: {
                          color: '#ff0000',
                        },
                        domProps: {
                          innerHTML: '*'
                        }
                      }),
                      h('span',{
                        domProps: {
                          innerHTML: '验收内容'
                        }
                      })
                    ])
                  }
                },

                {
                  title: `${ this.$t('preliminary.AcceptanceTestResult') }`,
                  key: 'checkResult',
                  align: 'center',
                  slot: 'checkResult',
                  // minWidth: 120
                  renderHeader: (h) => {
                    return h('div',[
                      h('span',{
                        style: {
                          color: '#ff0000',
                        },
                        domProps: {
                          innerHTML: '*'
                        }
                      }),
                      h('span',{
                        domProps: {
                          innerHTML: this.$t('preliminary.AcceptanceTestResult')
                        }
                      })
                    ])
                  }
                },
                {
                  title: `${ this.$t('preliminary.NonConformingReason') }`,
                  key: 'checkDesc',
                  align: 'center',
                  slot: 'checkDesc',
                  // minWidth: 120
                },
                {
                  title: `${ this.$t('preliminary.Version') }`,
                  key: 'version',
                  align: 'center',
                  slot: 'version',
                  // minWidth: 120
                  renderHeader: (h) => {
                    return h('div',[
                      h('span',{
                        style: {
                          color: '#ff0000',
                        },
                        domProps: {
                          innerHTML: '*'
                        }
                      }),
                      h('span',{
                        domProps: {
                          innerHTML: this.$t('preliminary.Version')
                        }
                      })
                    ])
                  }
                },
                // {
                //     title: `${ this.$t('common.operation') }`,
                //     key: 'action',
                //     align: 'center',
                //     slot: 'action'
                // }
              ],
                data: []
            }
        },
      mounted() {
          this.show(this.$route.query)
      },
      methods: {
          handleChangeDate(val) {
            this.formItem.yjyst = val
          },
          //技术资料删除
          delJSFileList(id) {
            this.jsFiles = this.jsFiles.filter((item, index) => index !=id)
          },
          //技术附件上传
          handleJSBeforeUpload(file) {
            this.jsFiles = []
            let formData = new FormData();
            formData.append("dir", 'device')
            formData.append("file",file)
            let config = {
              headers: {
                "Content-Type": "multipart/form-data"
              }
            };
            this.axios({
              method: 'post',
              url: '/fileServer/upload',
              data: formData,
              config,
            }).then(res => {
              if (res.code == 200) {
                this.jsFiles.push({
                  // attachmentType: 2,
                  fileName: res.data.fileName,
                  filePath: res.data.filepath,
                  fileUrl: res.data.fileUrl
                })
              }
            })
            return false;
          },
            show(record) {
                // 
                this.result = record.finalAcceptResult
                this.isShow = record.finalAcceptStatus ? true : false
                this.sendInfoVisible = true
                this.getDetail(record)
            },
            getDetail(record) {
                this.axios({
                    method: 'post',
                    url: '/dms/dmsCheck/get',
                    params: {
                        deviceMId: record.deviceMId
                    }
                }).then(res => {
                    
                    if (res.code == 200) {
                        this.$nextTick(() => {
                          if(res.data.checkList && res.data.checkList.length){
                            res.data.checkList.forEach(val=> {
                              val.showStatus = true
                              val.version = 'V' + val.version
                            })
                          }
                            this.formItem = res.data
                            this.jsFiles = res.data.jszlFile
                            // this.formItem.finalAcceptDate = this.result != 1 ? '' : res.data.finalAcceptDate
                            this.sjFlag = this.formItem.sjfjFile && this.formItem.sjfjFile.length ? 1 : 0
                            this.finallyFlag = this.formItem.zxjszlFile && this.formItem.zxjszlFile.length ? 1 : 0
                            this.cjFlag = this.formItem.cjpxFile && this.formItem.cjpxFile.length ? 1 : 0
                            this.aFlag = this.formItem.ajdFile && this.formItem.ajdFile.length ? 1 : 0
                            this.gFlag = this.formItem.gjdFile && this.formItem.gjdFile.length ? 1 : 0
                        })
                    }else {
                        this.$Message.warning(({content:res.msg,duration:6,closable:true}));
                    }
                })
            },
            //文件预览
            handlePreview(item) {
                if (item) {
                    window.open(this.util.filePathToUrl(item.filePath))
                }
            },
            //添加验收标准
            handleAddCheck() {
                this.formItem.checkList.push({
                  addStatus:true
                })
            },
            //验收指标
            handleTarget(e, index) {
                this.formItem.checkList[index].checkTarget = e.target.value
            },
            handleContent(e, index) {
                this.formItem.checkList[index].checkContent = e.target.value
            },
            handleResult(e, index) {
                console.log(e)
                this.formItem.checkList[index].checkResult = e
            },
            handleDesc(e, index) {
                this.formItem.checkList[index].checkDesc = e.target.value
            },
            //删除
            handleDelete(id) {
                this.formItem.checkList = this.formItem.checkList.filter((item, index) => id != index)
            },
            //下载验收文件
            exportCheck() {
                const filName = this.$t('acceptanceCheck.AcceptanceRecord')
                this.axios({
                    method: 'get',
                    url: '/dms/dmsCheck/exportYsWord',
                    responseType: 'blob',
                    params: {
                        deviceMId: this.formItem.deviceMId
                    }
                }).then(res => {
                    fileDownload(res, filName + '.doc')
                })
            },
            //下载精度文件
            exportAorG(type) {
                const filName = type == 'A' ? 'A'+this.$t('acceptanceCheck.AccuracyTestFile') : 'G'+this.$t('acceptanceCheck.AccuracyTestFile')
                this.axios({
                    method: 'get',
                    url: '/dms/dcmAcctestTask/exportFile1',
                    responseType: 'blob',
                    params: {
                        deviceMId: this.formItem.deviceMId,
                        type
                    }
                }).then(res => {
                    fileDownload(res, filName + '.xlsx')
                })
            },
          //保存
          handleSave() {
            let flag = false
            this.formItem.checkList.forEach(item => {
              if (item.checkTarget && item.checkContent && item.checkResult) {
                flag = true
              }
            })
            if (!this.formItem.checkList.length || !flag) {
              this.$Message.warning(({content: this.$t('acceptanceCheck.addAndInput'),duration:6,closable:true}));
              return false
            }
            this.loadingVisible = true
            const arr = this.formItem.checkList.filter(val=>val.addStatus === true)
            if (!(arr && arr.length)){
              this.$Message.error(this.$t('acceptanceCheck.inputCheck'))
              return
            }
            let dmsCheckList = arr.map( item => {
              return {
                checkTarget: item.checkTarget,
                checkContent: item.checkContent,
                checkResult: item.checkResult,
                // version: item.version,
                checkDesc: item.checkDesc ? item.checkDesc : ''
              }
            })
            let deviceMIdList = []
            deviceMIdList.push(this.formItem.deviceMId)
            let params = {
              deviceMIdList,
              dmsCheckList,
              version:1,
              yjyst: this.formItem.yjyst
            }
            if (Number(this.formItem.reAcceptanceTimes) !== 0){
              params.version = Number(this.formItem.reAcceptanceTimes) + 1
            }
            this.axios({
              method: 'post',
              url: '/dms/dmsCheck/add',
              data: params
            }).then(res => {
              if(res.code === 200){
                this.$emit('handleFresh')
                // this.sendInfoVisible = false
                this.$router.go(-1)
                this.$Message.success(({content:this.$t('acceptanceCheck.checkSuccess'),duration:3,closable:true}));
              }else{
                this.$Message.warning(({content:res.msg,duration:6,closable:true}));
              }
            }).finally(() => {
              this.loadingVisible = false
            })
          },
            handleVisibleChange() {}
        }
    }
</script>

<style scoped lang="scss">
    .basic-info {
        .basic-info-title {
            span {
                display: inline-block;
                width: 7px;
                height: 24px;
                background: #187bdb;
            }
            h2 {
                display: inline-block;
                font-size: 16px;
                padding-left: 10px;
                position: relative;
                &::before {
                    content:"";
                    position: absolute;
                    left: 0;
                    top: 0;
                    width: 7px;
                    height: 24px;
                    background: #187bdb;
                }
            }
        }
        .basic-info-body {
            margin: 10px;
            color: #333;
            font-size: 13px;
            font-family: 'Arial Normal', 'Arial', sans-serif;
            font-weight: 400;
            border-left: 1px solid #eee;
            .basic-info-body-label {
                display: inline-block;
                width: 40%;
                height: 48px;
                line-height: 48px;
                background: #f5f6f7;
                text-align: right;
                padding-right: 10px;
                /*border-left: 1px solid #B6B7B7;*/
                /*border-top: 1px solid #B6B7B7;*/
                /*border-bottom: 1px solid #B6B7B7;*/
            }
            .basic-info-body-item {
                /*display: inline-block;*/
                /*width: 60%;*/
                /*height: 48px;*/
                /*line-height: 48px;*/
                /*text-align: left;*/
                padding: 0 10px;
                /*border-left: 1px solid #eee;*/
                /*border-right: 1px solid #eee;*/
                /*border-right: 1px solid #B6B7B7;*/
                /*border-top: 1px solid #B6B7B7;*/
                /*border-bottom: 1px solid #B6B7B7;*/
            }
        }
    }
    .preview {
        position: absolute;
        right:10px;
        top:0;
        width: 35px;
        height: 35px;
        background: #eee;
        .preview-img {
            width: 35px;
            height: 35px;
            overflow: hidden;
        }
    }
    ::v-deep.ivu-form-item-label {
        /*display: inline-block;*/
        /*width: 40%;*/
        /*height: 48px;*/
        /*line-height: 48px;*/
        background: #f5f6f7;
        margin: 0;
        text-align: right;
        border-right: 1px solid #eee;
        /*padding-right: 10px;*/
    }
    ::v-deep.ivu-form-item {
        margin-bottom: 0;
        border-right: 1px solid #eee;
    }
    ::v-deep.Input-wrapper {
        width: 90%;
        margin: 0 10px;
        .ivu-select-selection {
            height: 30px;
            border: none;
            box-shadow: none;
        }
        .ivu-input {
            border: none;
            box-shadow: none;
        }
    }
    .btn-wrapper {
        position: relative;
        .btn-action {
            position: absolute;
            left: 0;
            right: 0;
            bottom: 0;
            top: 100px;
        }
    }
    .upload-wrapper {
        display: inline-block;
        position: relative;
        span {
            display: inline-block;
            width: 100px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            margin-bottom: -8px;
            line-height: 26px;
        }
        .upload-action {
            display: none;
            position: absolute;
            left: 0;
            right: 0;
            top: -1px;
            bottom: 0px;
            background: rgba(0,0,0,.6);
            i {
                cursor: pointer;
                margin: 0 10px;
            }
        }
        &:hover {
            .upload-action {
                display: inline-block;
            }
        }
    }
    ::v-deep.ivu-upload {
        margin-bottom: -15px;
        display: inline-block;
    }
    .over-wrapper {
        width: 200px;
        height: 23px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    ::v-deep.ivu-select-selected-value {
        background: #ffffff;
        color: #333333;
    }
    ::v-deep.ivu-input-disabled {
        background: #ffffff;
        color: #333333;
    }
    ::v-deep.ivu-select-placeholder {
        background: #ffffff;
        color: #333333;
    }
    ::v-deep.ivu-select-input {
        background: #fff;
        height:30px;
    }
    .file-list {
        width: 100%;
        margin: 0 20px;
        .item-src {
            width: 80%;
            display: inline-block;
            line-height: 26px;
            color: #187bdb;
            cursor: pointer;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        .item-icon {
            width: 20%;
            display: inline-block;
            margin-top: 4px;
        }
    }

</style>
